import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/discount/post_discount_entity.dart';
import 'package:flutter_deer/database/beans/get_user_info_entity.dart';

import 'package:flutter_deer/database/beans/pay/create_order_entity.dart';


PostDiscountEntity $PostDiscountEntityFromJson(Map<String, dynamic> json) {
  final PostDiscountEntity postDiscountEntity = PostDiscountEntity();
  final bool? compositePay = jsonConvert.convert<bool>(json['compositePay']);
  if (compositePay != null) {
    postDiscountEntity.compositePay = compositePay;
  }
  final List<Coupon>? couponList = (json['couponList'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<Coupon>(e) as Coupon).toList();
  if (couponList != null) {
    postDiscountEntity.couponList = couponList;
  }
  final int? couponSelectType = jsonConvert.convert<int>(json['couponSelectType']);
  if (couponSelectType != null) {
    postDiscountEntity.couponSelectType = couponSelectType;
  }
  final String? energyCategoryId = jsonConvert.convert<String>(json['energyCategoryId']);
  if (energyCategoryId != null) {
    postDiscountEntity.energyCategoryId = energyCategoryId;
  }
  final String? energyGoodsId = jsonConvert.convert<String>(json['energyGoodsId']);
  if (energyGoodsId != null) {
    postDiscountEntity.energyGoodsId = energyGoodsId;
  }
  final bool? fullPay = jsonConvert.convert<bool>(json['fullPay']);
  if (fullPay != null) {
    postDiscountEntity.fullPay = fullPay;
  }
  final int? lastPayAmount = jsonConvert.convert<int>(json['lastPayAmount']);
  if (lastPayAmount != null) {
    postDiscountEntity.lastPayAmount = lastPayAmount;
  }
  final String? loginMchCode = jsonConvert.convert<String>(json['loginMchCode']);
  if (loginMchCode != null) {
    postDiscountEntity.loginMchCode = loginMchCode;
  }
  final int? loginMchType = jsonConvert.convert<int>(json['loginMchType']);
  if (loginMchType != null) {
    postDiscountEntity.loginMchType = loginMchType;
  }
  final String? mchMemberId = jsonConvert.convert<String>(json['mchMemberId']);
  if (mchMemberId != null) {
    postDiscountEntity.mchMemberId = mchMemberId;
  }
  final String? memberAccountId = jsonConvert.convert<String>(json['memberAccountId']);
  if (memberAccountId != null) {
    postDiscountEntity.memberAccountId = memberAccountId;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['orderAmount']);
  if (orderAmount != null) {
    postDiscountEntity.orderAmount = orderAmount;
  }
  final int? paidAmount = jsonConvert.convert<int>(json['paidAmount']);
  if (paidAmount != null) {
    postDiscountEntity.paidAmount = paidAmount;
  }
  final int? payAmount = jsonConvert.convert<int>(json['payAmount']);
  if (payAmount != null) {
    postDiscountEntity.payAmount = payAmount;
  }
  final String? payType = jsonConvert.convert<String>(json['payType']);
  if (payType != null) {
    postDiscountEntity.payType = payType;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    postDiscountEntity.price = price;
  }
  final String? quantity = jsonConvert.convert<String>(json['quantity']);
  if (quantity != null) {
    postDiscountEntity.quantity = quantity;
  }
  final List<StoreGoodsInfos>? storeGoodsInfos = (json['storeGoodsInfos'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<StoreGoodsInfos>(e) as StoreGoodsInfos).toList();
  if (storeGoodsInfos != null) {
    postDiscountEntity.storeGoodsInfos = storeGoodsInfos;
  }
  final bool? useCoupon = jsonConvert.convert<bool>(json['useCoupon']);
  if (useCoupon != null) {
    postDiscountEntity.useCoupon = useCoupon;
  }
  final String? useIntegral = jsonConvert.convert<String>(json['useIntegral']);
  if (useIntegral != null) {
    postDiscountEntity.useIntegral = useIntegral;
  }
  return postDiscountEntity;
}

Map<String, dynamic> $PostDiscountEntityToJson(PostDiscountEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['compositePay'] = entity.compositePay;
  data['couponList'] = entity.couponList?.map((v) => v.toJson()).toList();
  data['couponSelectType'] = entity.couponSelectType;
  data['energyCategoryId'] = entity.energyCategoryId;
  data['energyGoodsId'] = entity.energyGoodsId;
  data['fullPay'] = entity.fullPay;
  data['lastPayAmount'] = entity.lastPayAmount;
  data['loginMchCode'] = entity.loginMchCode;
  data['loginMchType'] = entity.loginMchType;
  data['mchMemberId'] = entity.mchMemberId;
  data['memberAccountId'] = entity.memberAccountId;
  data['orderAmount'] = entity.orderAmount;
  data['paidAmount'] = entity.paidAmount;
  data['payAmount'] = entity.payAmount;
  data['payType'] = entity.payType;
  data['price'] = entity.price;
  data['quantity'] = entity.quantity;
  data['storeGoodsInfos'] = entity.storeGoodsInfos?.map((v) => v.toJson()).toList();
  data['useCoupon'] = entity.useCoupon;
  data['useIntegral'] = entity.useIntegral;
  return data;
}

extension PostDiscountEntityExtension on PostDiscountEntity {
  PostDiscountEntity copyWith({
    bool? compositePay,
    List<Coupon>? couponList,
    int? couponSelectType,
    String? energyCategoryId,
    String? energyGoodsId,
    bool? fullPay,
    int? lastPayAmount,
    String? loginMchCode,
    int? loginMchType,
    String? mchMemberId,
    String? memberAccountId,
    String? orderAmount,
    int? paidAmount,
    int? payAmount,
    String? payType,
    String? price,
    String? quantity,
    List<StoreGoodsInfos>? storeGoodsInfos,
    bool? useCoupon,
    String? useIntegral,
  }) {
    return PostDiscountEntity()
      ..compositePay = compositePay ?? this.compositePay
      ..couponList = couponList ?? this.couponList
      ..couponSelectType = couponSelectType ?? this.couponSelectType
      ..energyCategoryId = energyCategoryId ?? this.energyCategoryId
      ..energyGoodsId = energyGoodsId ?? this.energyGoodsId
      ..fullPay = fullPay ?? this.fullPay
      ..lastPayAmount = lastPayAmount ?? this.lastPayAmount
      ..loginMchCode = loginMchCode ?? this.loginMchCode
      ..loginMchType = loginMchType ?? this.loginMchType
      ..mchMemberId = mchMemberId ?? this.mchMemberId
      ..memberAccountId = memberAccountId ?? this.memberAccountId
      ..orderAmount = orderAmount ?? this.orderAmount
      ..paidAmount = paidAmount ?? this.paidAmount
      ..payAmount = payAmount ?? this.payAmount
      ..payType = payType ?? this.payType
      ..price = price ?? this.price
      ..quantity = quantity ?? this.quantity
      ..storeGoodsInfos = storeGoodsInfos ?? this.storeGoodsInfos
      ..useCoupon = useCoupon ?? this.useCoupon
      ..useIntegral = useIntegral ?? this.useIntegral;
  }
}

Coupon $CouponFromJson(Map<String, dynamic> json) {
  final Coupon coupon = Coupon();
  final int? couponNum = jsonConvert.convert<int>(json['couponNum']);
  if (couponNum != null) {
    coupon.couponNum = couponNum;
  }
  final String? mchCouponId = jsonConvert.convert<String>(json['mchCouponId']);
  if (mchCouponId != null) {
    coupon.mchCouponId = mchCouponId;
  }
  final String? memberCouponId = jsonConvert.convert<String>(json['memberCouponId']);
  if (memberCouponId != null) {
    coupon.memberCouponId = memberCouponId;
  }
  return coupon;
}

Map<String, dynamic> $CouponToJson(Coupon entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['couponNum'] = entity.couponNum;
  data['mchCouponId'] = entity.mchCouponId;
  data['memberCouponId'] = entity.memberCouponId;
  return data;
}

extension CouponExtension on Coupon {
  Coupon copyWith({
    int? couponNum,
    String? mchCouponId,
    String? memberCouponId,
  }) {
    return Coupon()
      ..couponNum = couponNum ?? this.couponNum
      ..mchCouponId = mchCouponId ?? this.mchCouponId
      ..memberCouponId = memberCouponId ?? this.memberCouponId;
  }
}